<?php
class EmailSendlistServer {
	public function batchSend($userData,$sendInfo){
		if (empty($userData)){
			return 1;
		}
		$tmp = array();
		$time = time();
		$info = HttpServerManager::getSendInfoTemplateServer()->getTitleAndContent($sendInfo);
		if (!is_array($info)){
			return $info;
		}
		foreach ($userData as $v){
			$tmp1['email'] = $v['email'];
			$tmp1['time'] = $time;
			$tmp1['title'] = $info['title'];
			$tmp1['content'] = $info['content'];
			array_push($tmp,$tmp1);
		}
		HttpDaoManager::getEmailSendlistDao()->addArray($tmp);
	} 
	
	public function   sendEmail($email,$title,$content,$is_html){
		$emailClass = ClassManager::getEmail();
		$emailClass->sendMailInternal('', $email,$title, $content,$is_html);
	}
	public function batchsendEmail($limit){
		$emailSendlistDao = HttpDaoManager::getEmailSendlistDao();
		$list  = $emailSendlistDao->getEmailList($limit);
		foreach ($list as $v){
			$this->sendEmail($v['email'],$v['title'], $v['content']);
			$tmp['status'] = 1;
			$emailSendlistDao->update($tmp, $v['id']);
		}
	}
}

?>